<?php
//var_dump($_POST);
$studentName = $_POST['StudentName'] ?? '';
$studentSex = $_POST['StudentSex'] ?? '';
$studentBirthday = $_POST['StudentBirth'] ?? '';
$studentAddress = $_POST['StudentAddress'] ?? '';

// 把学生信息存储到数据库
$dsn = "sqlsrv:Server=LAPTOP-G184I03M\SQLEXPRESS;Database=Student";
$db = new PDO($dsn, "sa", "123456");

$sql = "insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress) 
	values ('{$studentName}', '{$studentSex}', '{$studentBirthday}', '{$studentAddress}');";
$result = $db->exec($sql);
if ($result) {
    echo '增加学生成功';
} else {
    echo '增加失败';
}
